﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.SqlClient;
using System.Data;
using System.Security.Cryptography;


namespace BussModel
{
    /// <summary>
    /// ParaModel 的摘要描述
    /// </summary>
    public class ParaModel
    {
        private static ParaModel instance = null;

        public static ParaModel Instance
        {
            get
            {
                if (instance == null)
                {
                    instance = new ParaModel();
                }
                return instance;
            }
        }

        #region 定義資料庫對應Table的結構體
        public struct ParRegister
        {
            public SqlParameter Id;
            public SqlParameter UserName;
            public SqlParameter NickName;
            public SqlParameter Sex;
            public SqlParameter Salt;
            public SqlParameter Password;
            public SqlParameter AgainPassword;
            public SqlParameter Email;
            public SqlParameter CellPhone;
            public SqlParameter BirthDay;
            public SqlParameter Constellation;
            public SqlParameter Favorite;
            public SqlParameter RegisterDateTime;
      }


        public struct ParFavorite
        {
            public SqlParameter Fav;
            public SqlParameter Favorite;
        }


        public struct ParMyArticle
        {
            public SqlParameter ID;
            public SqlParameter ArticleID;
            public SqlParameter ArticleTitle;
            public SqlParameter Arti;
            public SqlParameter IsPublic;
        }


        public struct ParMyNiceFoodImage
        {
            public SqlParameter ID;
            public SqlParameter MyNiceFoodImageID;
            public SqlParameter MyNiceFoodImagePath;
            public SqlParameter IsPublic;
        }


        public struct ParMyNiceFoodVideo
        {
            public SqlParameter ID;
            public SqlParameter MyNiceFoodVideoID;
            public SqlParameter MyNiceFoodVideoPath;
            public SqlParameter IsPublic;
        }


        public struct ParMyTwniceFood
        {
            public SqlParameter ID;
            public SqlParameter Name;
            public SqlParameter ArticleID;
            public SqlParameter NiceFoodImageID;
            public SqlParameter NiceFoodVideoID;
        }
        #endregion

        public ParRegister GetParaRegister(RegisterModel entity)
        {
            ParRegister param = new ParRegister();

            param.Id = new SqlParameter("@Id", SqlDbType.UniqueIdentifier, 100);
            param.UserName = new SqlParameter("@UserName", SqlDbType.NVarChar, 100);
            param.NickName = new SqlParameter("@NickName", SqlDbType.NVarChar, 100);
            param.Sex = new SqlParameter("@Sex", SqlDbType.NVarChar, 100);
            param.Password = new SqlParameter("@Password", SqlDbType.NVarChar, 100);
            param.Salt = new SqlParameter(@"Salt", SqlDbType.NVarChar, 40);
            param.AgainPassword = new SqlParameter("@AgainPassword", SqlDbType.NVarChar, 100);
            param.Email = new SqlParameter("@Email", SqlDbType.NVarChar, 100);
            param.CellPhone = new SqlParameter("@CellPhone", SqlDbType.NVarChar, 100);
            param.BirthDay = new SqlParameter("@BirthDay", SqlDbType.NVarChar, 100);
            param.Constellation = new SqlParameter("@Constellation", SqlDbType.NVarChar, 30);
            param.Favorite = new SqlParameter("@Favorite", SqlDbType.NVarChar, 100);
            param.RegisterDateTime = new SqlParameter("@RegisterDateTime", SqlDbType.DateTime);

            param.AgainPassword.Value = entity.AgainPassword;
            param.Salt.Value = entity.Salt;
            param.BirthDay.Value = entity.BirthDay;
            param.CellPhone.Value = entity.CellPhone;
            param.Constellation.Value = entity.Constellation;
            param.Email.Value = entity.Email;
            param.Favorite.Value = entity.Favorite;
            param.Id.Value = entity.Id;
            param.NickName.Value = entity.NickName;
            param.Password.Value = entity.Password;
            param.RegisterDateTime.Value = entity.RegisterDateTime;
            param.Sex.Value = entity.Sex;
            param.UserName.Value = entity.UserName;

            return param;
        }

        public ParaModel()
        {
            //
            // TODO: 在此加入建構函式的程式碼
            //
        }


    }
}